package com.chenxiao.httputils.utils;

import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: CX
 * @Date: Created in  2023/12/10 22:41
 * @version: v1.0
 * @Description: TODO
 **/
public class RestTemplateUtils {
    public static String httpGet(String url) {
        RestTemplate restTemplate = new RestTemplate();
        String result = restTemplate.exchange(url, HttpMethod.GET, null, String.class).getBody();
        return result;
    }

    public static String httpPost(String url, String name) {
        RestTemplate restTemplate = new RestTemplate();
        return restTemplate.postForEntity(url, name, String.class).getBody();
    }
}
